/*     */ package com.newcrm.businessarchives;
/*     */ 
/*     */ import com.newcrm.bean.CaptchaEntity;
/*     */ import com.newcrm.exception.CaptchaException;
/*     */ import java.io.IOException;
/*     */ import java.io.PrintStream;
/*     */ import java.util.Date;
/*     */ import java.util.Iterator;
/*     */ import java.util.Map;
/*     */ import java.util.Map.Entry;
/*     */ import java.util.Set;
/*     */ import org.apache.log4j.Logger;
/*     */ import org.jsoup.Connection;
/*     */ import org.jsoup.Connection.Method;
/*     */ import org.jsoup.Connection.Response;
/*     */ import org.jsoup.Jsoup;
/*     */ import org.jsoup.nodes.Document;
/*     */ import org.jsoup.nodes.Element;
/*     */ import org.jsoup.select.Elements;
/*     */ 
/*     */ public class ShenzhenSearchEngine extends SearchEngine
/*     */   implements CaptchaSearchEngine
/*     */ {
/*  23 */   private static Logger logger = Logger.getLogger(ShenzhenSearchEngine.class
/*  24 */     .getName());
/*     */   private static final String IMAGE_URL = "http://app01.szaic.gov.cn/aiceqmis.webui/CheckCode.aspx?key=0";
/*     */ 
/*     */   public ShenzhenSearchEngine()
/*     */   {
/*     */   }
/*     */ 
/*     */   public ShenzhenSearchEngine(String name)
/*     */   {
/*  33 */     this.name = standardizedName(name);
/*     */   }
/*     */ 
/*     */   protected Map<String, Object> getCompanyByWeb()
/*     */     throws CaptchaException
/*     */   {
/*  39 */     String url = "http://app01.szaic.gov.cn/aiceqmis.webui/GeneralSearch.aspx";
/*  40 */     Connection connection = Jsoup.connect(url);
/*     */ 
/*  42 */     CaptchaEntityManager captchaEntityManager = 
/*  43 */       CaptchaEntityManager.getInstance();
/*  44 */     CaptchaEntity captchaEntity = captchaEntityManager.get(
/*  45 */       "sz", false);
/*  46 */     for (Map.Entry cookie : captchaEntity.cookies.entrySet()) {
/*  47 */       connection.cookie((String)cookie.getKey(), (String)cookie.getValue());
/*     */     }
/*     */ 
/*     */     try
/*     */     {
/*  52 */       Connection.Response res = connection
/*  53 */         .header("Host", "app01.szaic.gov.cn")
/*  54 */         .referrer(
/*  55 */         "http://app01.szaic.gov.cn/aiceqmis.webui/GeneralSearch.aspx")
/*  56 */         .data(new String[] { 
/*  56 */         "__EVENTVALIDATION", 
/*  57 */         (String)captchaEntity.extInfo.get("__EVENTVALIDATION"), 
/*  58 */         "__VIEWSTATE", 
/*  59 */         (String)captchaEntity.extInfo.get("__VIEWSTATE"), 
/*  60 */         "button_Search.x", "22", "button_Search.y", "19", 
/*  61 */         "hfIP", (String)captchaEntity.extInfo.get("hfIP"), 
/*  62 */         "txtEntName", this.name, "txtcheckCode", 
/*  63 */         this.captcha }).method(Connection.Method.POST)
/*  64 */         .userAgent("Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; GTB6.6; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; Tablet PC 2.0; .NET CLR 1.1.4322; .NET4.0C)").timeout(10000).execute();
/*     */ 
/*  66 */       Document doc = res.parse();
/*  67 */       System.out.println(doc.html());
/*     */     }
/*     */     catch (IOException e) {
/*  70 */       logger.warn("get guangzhou company info failed", e);
/*     */     }
/*     */ 
/*  73 */     return null;
/*     */   }
/*     */ 
/*     */   public CaptchaEntity downloadImage() {
/*  77 */     String url = "http://app01.szaic.gov.cn/aiceqmis.webui/GeneralSearch.aspx";
/*  78 */     Connection connection = Jsoup.connect(url);
/*  79 */     CaptchaEntity captchaEntity = new CaptchaEntity();
/*     */     try
/*     */     {
/*  83 */       Connection.Response res = connection.userAgent("Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; GTB6.6; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; Tablet PC 2.0; .NET CLR 1.1.4322; .NET4.0C)").timeout(10000).execute();
/*  84 */       res.contentType();
/*  85 */       captchaEntity.cookies = res.cookies();
/*  86 */       Document doc = res.parse();
/*  87 */       String hfIP = "";
/*  88 */       Elements inputs = doc.select("input[name=hfIP]");
/*  89 */       if ((inputs != null) && (inputs.size() > 0)) {
/*  90 */         hfIP = inputs.get(0).attr("value");
/*     */       }
/*  92 */       captchaEntity.extInfo.put("hfIP", hfIP);
/*     */ 
/*  95 */       Connection connection2 = Jsoup.connect(url);
/*     */ 
/*  97 */       Iterator localIterator1 = captchaEntity.cookies
/*  97 */         .entrySet().iterator();
/*     */ 
/*  96 */       while (localIterator1.hasNext()) {
/*  97 */         Map.Entry cookie = (Map.Entry)localIterator1.next();
/*  98 */         connection2.cookie((String)cookie.getKey(), (String)cookie.getValue());
/*     */       }
/* 100 */       res = connection2
/* 101 */         .data("hfIp", hfIP)
/* 102 */         .method(Connection.Method.POST)
/* 103 */         .referrer(
/* 104 */         "http://app.szaic.gov.cn/CheckPage.WebUI/Index.aspx?PURL=http://app01.szaic.gov.cn/aiceqmis.webui/GeneralSearch.aspx")
/* 105 */         .userAgent("Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; GTB6.6; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; Tablet PC 2.0; .NET CLR 1.1.4322; .NET4.0C)").timeout(10000).execute();
/* 106 */       res.contentType();
/* 107 */       captchaEntity.cookies = res.cookies();
/* 108 */       doc = res.parse();
/*     */ 
/* 110 */       String eventvalidation = "";
/* 111 */       String viewstate = "";
/* 112 */       inputs = doc.select("input[name=__EVENTVALIDATION]");
/* 113 */       if ((inputs != null) && (inputs.size() > 0)) {
/* 114 */         eventvalidation = inputs.get(0).attr("value");
/*     */       }
/* 116 */       captchaEntity.extInfo.put("__EVENTVALIDATION", eventvalidation);
/*     */ 
/* 118 */       inputs = doc.select("input[name=__VIEWSTATE]");
/* 119 */       if ((inputs != null) && (inputs.size() > 0)) {
/* 120 */         viewstate = inputs.get(0).attr("value");
/*     */       }
/* 122 */       captchaEntity.extInfo.put("__VIEWSTATE", viewstate);
/*     */ 
/* 124 */       Connection connection3 = Jsoup.connect("http://app01.szaic.gov.cn/aiceqmis.webui/CheckCode.aspx?key=0");
/*     */ 
/* 126 */       Iterator localIterator2 = captchaEntity.cookies
/* 126 */         .entrySet().iterator();
/*     */ 
/* 125 */       while (localIterator2.hasNext()) {
/* 126 */         Map.Entry cookie = (Map.Entry)localIterator2.next();
/* 127 */         connection3.cookie((String)cookie.getKey(), (String)cookie.getValue());
/*     */       }
/*     */ 
/* 130 */       res = connection3
/* 131 */         .userAgent("Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; GTB6.6; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; Tablet PC 2.0; .NET CLR 1.1.4322; .NET4.0C)")
/* 132 */         .header("Host", "app01.szaic.gov.cn")
/* 133 */         .referrer(
/* 134 */         "http://app01.szaic.gov.cn/aiceqmis.webui/GeneralSearch.aspx")
/* 135 */         .timeout(10000).execute();
/* 136 */       res.contentType();
/* 137 */       captchaEntity.cookies = res.cookies();
/* 138 */       captchaEntity.image = res.bodyAsBytes();
/* 139 */       captchaEntity.createDate = new Date();
/* 140 */       captchaEntity.code = "";
/* 141 */       return captchaEntity;
/*     */     } catch (IOException e) {
/* 143 */       logger.warn("get guangzhou company info failed", e);
/*     */     }
/*     */ 
/* 146 */     return null;
/*     */   }
/*     */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     com.newcrm.businessarchives.ShenzhenSearchEngine
 * JD-Core Version:    0.6.1
 */